"""用户评分配置模块.

本模块定义用户信用评分系统的配置:

1. 信用额度配置
   - 免押额度
   - 延迟付款期限
   - 信用透支额度
   - 分期付款额度

2. 信用恢复要求
   - 最低订单数
   - 最低交易金额
   - 清洁期要求
   - 额外条件

3. 积分调整配置
   - 行为奖励积分
   - 违规扣分规则
   - 分数衰减规则

4. 风险阈值配置
   - 交易金额限制
   - 频率限制
   - 信用分数门槛
"""

from typing import Dict

# 信用额度配置
CREDIT_LIMITS: Dict[str, Dict[str, float]] = {
    "S+": {  # 钻石级额度
        "deposit_free_limit": 50000,     # 免押金额度
        "delay_payment_days": 45,        # 延迟付款天数
        "credit_line": 100000,          # 信用额度
        "installment_limit": 200000      # 分期额度
    },
    "S": {   # 金牌级额度
        "deposit_free_limit": 30000,
        "delay_payment_days": 30,
        "credit_line": 60000,
        "installment_limit": 120000
    },
    "A+": {  # 银牌级额度
        "deposit_free_limit": 20000,
        "delay_payment_days": 15,
        "credit_line": 40000,
        "installment_limit": 80000
    },
    "A": {   # 铜牌级额度
        "deposit_free_limit": 10000,
        "delay_payment_days": 7,
        "credit_line": 20000,
        "installment_limit": 40000
    },
    "B+": {  # 信用级额度
        "deposit_free_limit": 5000,
        "delay_payment_days": 3,
        "credit_line": 10000,
        "installment_limit": 20000
    },
    "B": {   # 观察级额度
        "deposit_free_limit": 2000,
        "delay_payment_days": 0,
        "credit_line": 5000,
        "installment_limit": 10000
    },
    "C+": {  # 受限级额度
        "deposit_free_limit": 1000,
        "delay_payment_days": 0,
        "credit_line": 2000,
        "installment_limit": 5000
    },
    "C": {   # 高危级额度
        "deposit_free_limit": 0,
        "delay_payment_days": 0,
        "credit_line": 1000,
        "installment_limit": 2000
    },
    "D": {   # 禁止级额度
        "deposit_free_limit": 0,
        "delay_payment_days": 0,
        "credit_line": 0,
        "installment_limit": 0
    }
}

# 信用恢复要求配置
RECOVERY_REQUIREMENTS: Dict[str, Dict[str, any]] = {
    "C": {   # C级恢复要求
        "min_good_orders": 5,        # 最少成功订单数
        "min_amount": 2000,          # 最低交易金额
        "clean_period": 30,          # 清洁期(天)
        "extra_conditions": [        # 额外条件
            "无退货记录",
            "无投诉记录",
            "无争议订单"
        ]
    },
    "C+": {  # C+级恢复要求
        "min_good_orders": 8,
        "min_amount": 5000,
        "clean_period": 45,
        "extra_conditions": [
            "无退货记录",
            "无投诉记录"
        ]
    },
    "B": {   # B级恢复要求
        "min_good_orders": 10,
        "min_amount": 10000,
        "clean_period": 60,
        "extra_conditions": [
            "无严重违规"
        ]
    }
}

# 行为奖励积分配置
ACTIVITY_BONUS: Dict[str, float] = {
    "complete_profile": 5.0,     # 完善个人资料
    "verify_identity": 10.0,     # 实名认证
    "bind_phone": 5.0,           # 绑定手机
    "good_review": 2.0,          # 好评
    "share_product": 1.0,        # 分享商品
    "first_order": 10.0,         # 首单奖励
    "continuous_purchase": 5.0,   # 连续购买
    "high_value_order": 8.0,     # 高额订单
    "platform_activity": 3.0      # 平台活动参与
}

# 违规扣分配置
PENALTY_POINTS: Dict[str, float] = {
    "late_payment": -10.0,       # 逾期付款
    "order_dispute": -5.0,       # 订单争议
    "malicious_complaint": -20.0, # 恶意投诉
    "false_review": -15.0,       # 虚假评价
    "abuse_return": -10.0,       # 滥用退货
    "violation_rules": -30.0      # 违反平台规则
}

# 分数衰减规则
SCORE_DECAY = {
    "daily_rate": 0.1,           # 每日衰减率
    "inactive_rate": 0.5,        # 不活跃衰减率
    "minimum_score": 50.0        # 最低保留分数
}

# 分数调整配置
SCORE_ADJUSTMENTS = {
    "recovery_bonus": 50.0,      # 信用恢复奖励
    "seasonal_bonus": 20.0,      # 季节性奖励
    "loyalty_bonus": 30.0,       # 忠诚度奖励
    "quick_payment": 5.0,        # 快速付款奖励
    "early_warning": -20.0       # 预警扣分
}

# 风险阈值配置
RISK_THRESHOLDS = {
    "single_transaction": 50000,  # 单笔交易限额
    "daily_transaction": 100000,  # 每日交易限额
    "monthly_transaction": 500000, # 每月交易限额
    "max_orders_per_hour": 10,    # 每小时最大订单数
    "max_orders_per_day": 50,     # 每日最大订单数
    "min_credit_score": 200,      # 最低信用分
    "warning_score": 300          # 预警分数线
}